  <!-- Right side column. Contains the navbar and content of the page -->
            <aside class="right-side">                
                <!-- Content Header (Page header) -->
                <section class="content-header">
                    <h1>
                        Galerie
                        <small>Control panel</small>
                    </h1>
                    <ol class="breadcrumb">
                        <li><a href="<?=site_url()?>"><i class="fa fa-dashboard"></i> Accueil</a></li>
                        <li class="active">Galerie</li>
                    </ol>
                </section>

                <!-- Main content -->
                <section class="content">

                    <!-- Small boxes (Stat box) -->
                    <div class="row">
                     <div class="post-box col-xs-12 col-sm-6 col-md-3 ">
    <div class="thumbnail">
     
      <a href="<?=site_url()?>gallery/publics/upload"   class="btn btn-lg btn-primary btn-block">
      	<i class="fa fa-plus-circle"></i> Ajouter une photo
		</a>

    </div>
  </div>
                      <?php foreach ($photos as $p):?>
                      	 <div class="post-box col-xs-12 col-sm-6 col-md-3 item_<?=$p->id?>">
    <div class="thumbnail">
     
      <a href="<?=base_url()?>uploads/gallery/large/<?=$p->filename_l?>" title="<?=$p->filename_l?>"  data-gallery="">
       <img src="<?=base_url()?>uploads/gallery/thumbs/<?=$p->filename_s?>" alt="..." >
		</a>
      <div class="caption">
     	<p><b>Crée:</b> <?=date('d-M-Y  @ H:i',strtotime($p->date))?> <b>par</b> <?=$p->aauth_user->name?></p>
        <p>
       	
        <button type="button" class="btn btn-danger btn-xs" role="button" onclick="deleteItem(<?=$p->id?>,'<?=$p->filename_s?>')"><i class="glyphicon glyphicon-trash"></i></button> | 
        <a  class="btn btn-danger btn-xs" href="<?=base_url()?>uploads/gallery/large/<?=$p->filename_l?>" target="_blank"><i class="fa fa-download"></i></a>
        </p>
        
      </div>
    </div>
  </div>
                      <?php endforeach;?>
                    </div><!-- /.row -->

                </section><!-- /.content -->
            </aside><!-- /.right-side -->
        </div><!-- ./wrapper -->
        
                
        <!-- The blueimp Gallery widget -->
<div id="blueimp-gallery" class="blueimp-gallery blueimp-gallery-controls" >
    <div class="slides"></div>
    <h3 class="title"></h3>
    <a class="prev">‹</a>
    <a class="next">›</a>
    <a class="close">×</a>
    <a class="play-pause"></a>
    <ol class="indicator"></ol>
</div>
<div id="deleteItem" class="modal fade " tabindex="-1" role="dialog"
		aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">×</button>
					<h4 id="myModalLabel">Action:</h4>
				</div>
				<div class="modal-body">Voulez-vous supprimer cette photo?</div>
				<div class="modal-footer">
					
					
				</div>
			</div>
		</div>
	</div>	
<script>

function deleteItem(id, thumb) {
	$('#deleteItem .modal-body').html(
			'<p><img src="../uploads/gallery/thumbs/' + thumb + '"></p>'
					+ '<p>Voulez-vous supprimer cette photo ?<br><b><small>'
					+ thumb + '</small></b></p>');
	$('#deleteItem .modal-footer')
			.html(
					'<button class="btn" data-dismiss="modal" aria-hidden="true">Non <i class="glyphicon glyphicon-ban-circle"></i></button>'
							+ '<button class="btn btn-danger" onclick="doDelete('
							+ id
							+ ')">Oui <i class="glyphicon glyphicon-trash"></i></button>');
	$('#deleteItem').modal({})
}

function doDelete($id) {
	var url = "<?=site_url()?>gallery/publics/deleteItem";
	
	$.post(url,{id : $id},function(data) {
						var arr = JSON.parse(data);
						if (arr.result == true) {
							$('#deleteItem .modal-body')
									.append(
											'<p class="alert alert-success">Cette photo a été supprimé.</p>');
							$('.row .item_' + $id).fadeOut();

						} else {
							$('#deleteItem .modal-body')
									.append(
											'<p class="alert alert-danger">Erreur, cette photo ne peut pas être supprimée.</p>');
						}

						$('#deleteItem .modal-footer')
								.html(
										'<button class="btn btn-primary" onclick="reloadCurrentPage()">ok</button>');
						
					});
}
function reloadCurrentPage()
{
	location.reload();
}	

</script>